#!/usr/bin/env bash
#
# setup the Vim Configuration of Champions

info () {
  printf "  [ \033[00;34m..\033[0m ] $1\n"
}

success () {
  printf "\r\033[2K  [ \033[00;32mOK\033[0m ] $1\n"
}

fail () {
  printf "\r\033[2K  [\033[0;31mFAIL\033[0m] $1\n"
  echo ''
  exit
}

echo ''
info 'Setting up the Vim Configuration of Champions'
info '============================================='
echo ''

info 'Setting up Symlinks'
info '--------------'
if test $(which rake)
then
  rake vim:link
else
  fail 'Install Ruby and Rake to continue'
fi

info 'Installing plugins'
info '-------------------------------------------------'
if test $(which nvim)
then
  nvim -v +PluginInstall +qall
else
  if test $(which vim)
  then
    vim +PluginInstall +qall
  else
    fail 'nvim or vim not found in path.'
  fi
fi

success 'Setup complete. Run vim and enjoy'
